package org.hawk.gwtppc.webtest.tests.bugssuite;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.List;

import org.hawk.gwt.ppc.reflect.lang.GWTClassType;
import org.hawk.gwtppc.webtest.common.Asserts;
import org.hawk.gwtppc.webtest.common.Test;
import org.hawk.gwtppc.webtest.tests.mock.ParameterizedFieldMock;

public class Bug_23 implements Test {

	public void run() throws Throwable {
		Type type = ParameterizedFieldMock.class.getDeclaredField("objs").getGenericType();
		
		Asserts.assertNotNull(type);
		Asserts.assertTrue(type instanceof ParameterizedType);
		ParameterizedType ptype = (ParameterizedType) type;
		Asserts.assertEquals(((GWTClassType<?>) ptype.getRawType()).toClass(), List.class);
		Asserts.assertEquals(ptype.getActualTypeArguments().length, 1);

		Asserts.assertTrue(ptype.getActualTypeArguments()[0] instanceof TypeVariable);
		TypeVariable<?> typeVariable = (TypeVariable<?>)ptype.getActualTypeArguments()[0];
		Asserts.assertEquals(typeVariable.getName(), "T");
	}

	public String getName() {
		return "#23";
	}

}
